import os
import os.path as osp
import shutil

QueryDIR = osp.abspath('./txt')
KeyDIR = osp.abspath('./xml')
OUTDIR = osp.abspath('./new')

names = [name[:-4] for name in os.listdir(QueryDIR) if name.endswith('.txt')]
for name in names:
    old_name = osp.join(KeyDIR, name+'.xml')
    new_name = osp.join(OUTDIR, name+'.xml')
    shutil.copyfile(old_name, new_name)
    print(name, 'done')
